/**
 * Copyright (C) 2009+ Spark Zheng
 *
 * @file        src/dserver.h 
 * @date        2010-04-05
 * @brief	server_framework
 * @see         dserver
 * @history
 */

#ifndef _DSERVER_MAIN_H
#define _DSERVER_MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

#include <dlib/global.h>
#include <dlib/lock.h>
#include <dlib/confloose.h>

typedef struct dserver_setting	dserver_setting_t;
typedef struct pipeline_context	dserver_pipeline_t;
typedef struct filter_context	dserver_filter_t;
typedef struct protocol_context	dserver_protocol_t;
typedef struct reactor_context	dserver_reactor_t;
typedef struct dserver_context	dserver_t;

struct dserver_setting {
	char		*conf_file;	/** config file path */
	char		*log_path;	/** log file path */
	char		*pid_file;	/** pid file path */

	char		*user;		/** running user */
	char		*group;		/** running group */

	uint32_t	max_fds;	/** max filedescripts on server */
	uint32_t	max_conns;	/** max conn-structs in reactor */

	uint32_t	rx_buf;		/** runtime receive buffer size */
	uint32_t	tx_buf;		/** runtime sendout buffer size */

	char		*protocols;	/** server loaded protocols */
	char		*protocols_dir;	/** protocols so dir */
	char		*filters;	/** server loaded filters */
	char		*filters_dir;	/** filters so dir */
	
	char		*mont_host;	/** monitor host name or ip address */
	uint16_t	mont_port;	/** monitor port for main process */
	uint16_t	mont_timeout;	/** monitor timeout for main process */
	uint16_t	mont_priority;	/** monitor priority for main process */

	dlib_confl_t	*dserver_confl;	/** confloose, pass to protocols & filters */
};

struct dserver_context {
	dserver_setting_t	*settings;

	dserver_reactor_t	*reactor;
	dserver_protocol_t	*protocols;
	dserver_filter_t	*filters;
	dserver_pipeline_t	*pipelines;

	dlib_lock_t		dserver_lock;
};

#ifdef __cplusplus
}
#endif
#endif
